export function score(testData) {
	return new Promise((resolve, reject) => {
		
	
	let grounp1res = 0
	let grounp2res = 0
	let grounp3res = 0
	let grounp4res = 0
	let grounp5res = 0
	let params = {
		value1: "",
		value2: "",
		value3: "",
		value4: "",
		value5: ""
	}
	console.log('grounp1res', testData)
	for (let i = 0; i < testData.test0.length; i++) {
		const ele = testData.test0[i]
		grounp1res += parseInt(ele.userScore)
	}

	console.log('grounp2res')
	for (let i = 0; i < testData.test1.length; i++) {
		const ele = testData.test1[i]
		grounp2res += parseInt(ele.userScore)
	}
	if (grounp2res == 100) params.value1 = '0'
	if (grounp2res >= 65 && grounp2res <= 95) params.value1 = '1'
	if (grounp2res >= 45 && grounp2res <= 60) params.value1 = '2'
	if (grounp2res <= 40) params.value1 = '3'

	console.log('grounp3res')
	for (let i = 0; i < testData.test2.length; i++) {
		const ele = testData.test2[i]
		grounp3res += parseInt(ele.userScore)
	}
	if (grounp3res == 0) params.value2 = '0'
	if (grounp3res == 1) params.value2 = '1'
	if (grounp3res == 2 || grounp3res == 3) params.value2 = '2'
	if (grounp3res >= 4 && grounp3res <= 6) params.value2 = '3'

	console.log('grounp4res')
	for (let i = 0; i < testData.test3.length; i++) {
		const ele = testData.test3[i]
		grounp4res += parseInt(ele.userScore)
	}
	if (grounp4res == 0) params.value2 = '0'
	if (grounp4res == 1) params.value2 = '1'
	if (grounp4res == 2 || grounp3res == 3) params.value2 = '2'
	if (grounp4res >= 4 && grounp3res <= 6) params.value2 = '3'

	console.log('grounp5res')
	for (let i = 0; i < testData.test4.length; i++) {
		const ele = testData.test4[i]
		grounp5res += parseInt(ele.userScore)
	}
	if (grounp5res >= 0 && grounp5res <= 2) params.value4 = '0'
	if (grounp5res >= 3 && grounp5res <= 7) params.value4 = '1'
	if (grounp5res >= 8 && grounp5res <= 13) params.value4 = '2'
	if (grounp5res >= 14 && grounp5res <= 20) params.value4 = '3'

	if (testData.test3[0].userScore == 0) {
		if (testData.test3[1].userScore < 2 && testData.test3[2].userScore < 2 && testData.test3[3].userScore == 0) {
			// console.log('能力完好') 
			params.value3 = '0'
		} else if ((testData.test3[1].userScore == 2 || testData.test3[2].userScore == 2) || testData.test3[3].userScore == 1) {
			// console.log('轻度受损')
			params.value3 = '1'
		} else if (testData.test3[1].userScore == 3 || testData.test3[2].userScore == 3 || testData.test3[3].userScore == 2) {
			params.value3 = '2'
			// console.log('中度受损')
		}
	}
	if (testData.test3[0].userScore == 1) {
		if ((testData.test3[1].userScore < 3 || testData.test3[2].userScore < 3) && testData.test3[3].userScore <= 2) {
			params.value3 = '2'
		}
	}
	if (testData.test3[0].userScore == 1 || testData.test3[0].userScore == 0) {
		if (testData.test3[1].userScore == 4 || testData.test3[2].userScore == 4 || testData.test3[3].userScore == 3) {
			// console.log('重度受损')
			params.value3 = '3'
		}
	}
	if (testData.test3[0].userScore == 2 || testData.test3[0].userScore == 3) {
		// console.log('重度受损')
		params.value3 = '3'
	}


	if (params.value1 == '0' && params.value2 == '0' && params.value3 == '0' && (params.value4 == '0' || params.value4 ==
			'1')) {
		params.value5 = '0'
	} else if (params.value1 == '0' && (params.value2 != '0') && (params.value3 != '0') && (params.value4 == '2' || params
			.value4 ==
			'3')) {
		params.value5 = '1'
	} else if (params.value1 == '1' && (params.value2 == '0' || params.value2 == '1') && (params.value3 == '0' || params.value3 ==
			'1') && (params.value4 == '0' || params.value4 == '1')) {
		params.value5 = '1'
	} else if (params.value1 == '1' && (params.value2 < '2' || params.value3 < '2' || params.value4 < '2')) {
		params.value5 = '1'
	} else if (params.value1 == '0' && (params.value2 >= '1' || params.value3 >= '1' || params.value4 == '2')) {
		params.value5 = '1'
	} else if (params.value1 == '1' && (params.value2 == '2' || params.value2 == '3') && (params.value3 == '2' || params.value3 ==
			'3') && (params.value4 == '2' || params.value4 == '3')) {
		params.value5 = '2'
	} else if (params.value1 == '2' && (params.value2 != '3') && (params.value3 != '3') && (params.value4 != '3')) {
		params.value5 = '2'
	} else if (params.value1 == '1' && (params.value2 == '3' || params.value3 == '3' || params.value4 == '3')) {
		params.value5 = '2'
	} else if (params.value1 == '2' && (params.value2 == '2' || params.value2 == '3') && (params.value3 == '2' || params.value3 ==
			'3') && (params.value4 == '2' || params.value4 == '3')) {
		params.value5 = '3'
	} else if (params.value1 == '2' && (params.value2 == '3' || params.value3 == '3' || params.value4 == '3')) {
		params.value5 = '3'
	} else if (params.value1 == '3') {
		params.value5 = '3'
	}
	
	if (testData.test2[0].userScore == 2 || testData.test0[0] > 0 || testData.test0[1] > 0){
		params.value5 = parseInt(params.value5) + 1
	}
	if (testData.test2[2].userScore > 1 || testData.test0[3] > 1 || testData.test0[4] > 1 || testData.test0[5] > 1){
		params.value5 = parseInt(params.value5) + 1
	}
	if (testData.test3[0].userScore == 3){
		params.value5 = 3
	}
	resolve(params)
	})
}
